{include file='public/_meta'}
<title>仓库信息管理</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 基础设置 <span class="c-gray en">&gt;</span> 仓库信息管理 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<div class="text-c">
		<form class="Huiform" method="post" action="{:url('admin/ckgl/index')}" target="_self">
			<input type="text" class="input-text" style="width:250px" placeholder="仓库名称" id="keywords" name="keywords">
			<button type="submit" class="btn btn-success" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 搜仓库名称</button>
		</form>
	</div>
	<div class="cl pd-5 bg-1 bk-gray mt-20" style="margin-bottom: 10px;">
      <span class="l">
          <a href="javascript:;" onclick="datadel()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a>
          <a href="javascript:;" onclick="admin_ckgl_add('添加仓库','add.html','370','320')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加仓库</a>
      </span> <span class="r">共有数据：<strong>{$totalcounts}</strong> 条</span> </div>
	<table class="table table-border table-bordered table-bg table-sort">
		<thead>
		<tr>
			<th scope="col" colspan="8">仓库信息</th>
		</tr>
		<tr class="text-c">
			<th width="25"><input type="checkbox" name="" value=""></th>
			<th width="40">ID</th>
			<th width="120">一级仓库</th>
			<th style="text-align:left;">二级仓库</th>
			<th width="100">管理员</th>
			<th width="120">联系电话</th>
			<th width="70">状态</th>
			<th width="100">操作</th>
		</tr>
		</thead>
		<tbody>
		{if $list}
			{foreach $list as $k=>$v}
			<tr class="text-c">
				<td><input type="checkbox" value="{$v.id}" name=""></td>
				<td>{$v.id}</td>
				<td>{$v.title}</td>
				<td style="text-align:left;"></td>
				<td>{$v.lxr}</td>
				<td>{$v.phone}</td>
				<td class="td-status"><span class="label {if $v.status=='启用'}label-success{/if} radius">{$v.status}</span></td>
				<td class="td-manage">
					{if $v.status=='启用'}
					<a style="text-decoration:none" onClick="admin_stop(this,'{$v.id}')" href="javascript:;" title="禁用"><i class="Hui-iconfont">&#xe631;</i></a>
					{else}
					<a style="text-decoration:none" onClick="admin_start(this,'{$v.id}')" href="javascript:;" title="启用"><i class="Hui-iconfont">&#xe615;</i></a>
					{/if}
					<a title="编辑仓库信息" href="javascript:;" onclick="admin_ckgl_edit('编辑仓库信息','<?php echo url('admin/ckgl/edit',['id'=>$v['id']]);?>','370','320')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a>
					<a title="删除" href="javascript:;" onclick="admin_ckgl_del(this,'{$v.id}')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
				</td>
			</tr>
			{if isset($v.childrens)}
			{foreach $v.childrens as $ck=>$cv}
			<tr class="text-c">
				<td><input type="checkbox" value="{$cv.id}" name=""></td>
				<td>{$cv.id}</td>
				<td>--</td>
				<td style="text-align:left;">|-- {$cv.title}</td>
				<td>{$cv.lxr}</td>
				<td>{$cv.phone}</td>
				<td class="td-status"><span class="label {if $cv.status=='启用'}label-success{/if} radius">{$cv.status}</span></td>
				<td class="td-manage">
					{if $cv.status=='启用'}
					<a style="text-decoration:none" onClick="admin_stop(this,'{$cv.id}')" href="javascript:;" title="停用"><i class="Hui-iconfont">&#xe631;</i></a>
					{else}
					<a style="text-decoration:none" onClick="admin_start(this,'{$cv.id}')" href="javascript:;" title="启用"><i class="Hui-iconfont">&#xe615;</i></a>
					{/if}
					<a title="编辑仓库信息" href="javascript:;" onclick="admin_ckgl_edit('编辑仓库信息','<?php echo url('admin/ckgl/edit',['id'=>$cv['id']]);?>','370','320')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a>
					<a title="删除" href="javascript:;" onclick="admin_ckgl_del(this,'{$cv.id}')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
				</td>
			</tr>
			{/foreach}
			{/if}
			{/foreach}
		{/if}
		</tbody>
	</table>
</div>
<!--_footer 作为公共模版分离出去-->
{include file='public/_footer'}
<!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__PUBLIC__lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="__PUBLIC__lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript" src="__PUBLIC__lib/jquery.treetable.js"></script>
<script type="text/javascript">
    //$(function(){
        $('.table-sort').dataTable({
            "aaSorting": [[ 1, "asc" ]],//默认第几个排序
            "bStateSave": true,//状态保存
            "aoColumnDefs": [
                //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
                {"orderable":false,"aTargets":[0,3,4]}// 制定列不参与排序
            ],
            language : {
                "sProcessing": "处理中...",
                "sLengthMenu": "显示 _MENU_ 项结果",
                "sZeroRecords": "没有匹配结果",
                "sInfo": "显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项",
                "sInfoEmpty": "显示第 0 至 0 项结果，共 0 项",
                "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
                "sInfoPostFix": "",
                "sSearch": "搜索：",
                "sUrl": "",
                "sEmptyTable": "表中数据为空",
                "sLoadingRecords": "载入中...",
                "sInfoThousands": ",",
                "oPaginate": {
                    "sFirst": "首页",
                    "sPrevious": "上页",
                    "sNext": "下页",
                    "sLast": "末页"
                },
                "oAria": {
                    "sSortAscending": ": 以升序排列此列",
                    "sSortDescending": ": 以降序排列此列"
                }
            }
        });
    //});
    /*
        参数解释：
        title	标题
        url		请求的url
        id		需要操作的数据id
        w		弹出层宽度（缺省调默认值）
        h		弹出层高度（缺省调默认值）
    */
    /*管理员-仓库信息-添加*/
    function admin_ckgl_add(title,url,w,h){
        layer_show(title,url,w,h);
    }
    /*管理员-仓库信息-编辑*/
    function admin_ckgl_edit(title,url,w,h){
        layer_show(title,url,w,h);
    }
    /*管理员-仓库信息-权限设置*/
    function admin_ckgl_set(title,url,w,h){
        layer_show(title,url,w,h);
    }

    /*管理员-停用*/
    function admin_stop(obj,id){
        layer.confirm('确认要停用吗？',function(index){
            //此处请求后台程序，下方是成功后的前台处理……
			$.getJSON("{:url('admin/ckgl/set')}",{'id':id,'status':0},function(data){
			    if(parseInt(data.statusCode)==200){
                    location.reload();
                    layer.msg('已停用!',{icon: 5,time:1000});
				}else{
                    layer.msg(data.message,{icon: 5,time:1000});
				}
			});

        });
    }

    /*管理员-启用*/
    function admin_start(obj,id){
        layer.confirm('确认要启用吗？',function(index){
            //此处请求后台程序，下方是成功后的前台处理……
            $.getJSON("{:url('admin/ckgl/set')}",{'id':id,'status':1},function(data){
                if(parseInt(data.statusCode)==200) {
                    location.reload();
                    layer.msg('启用!', {icon: 6, time: 1000});
                }else{
                    layer.msg(data.message,{icon: 5,time:1000});
                }
			});


        });
    }


    /*管理员-仓库信息-删除*/
    function admin_ckgl_del(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            $.getJSON("delete.html",{'ids':id},function(res){
                if(parseInt(res.statusCode)==200){
                    $(obj).parents("tr").remove();
                    layer.msg(res.message,{icon:1,time:1000});
                    window.location.reload();
                }else{
                    layer.msg(res.message);
                }
            });
        });
    }

    function datadel(){
        var gid = '';
        layer.confirm('确定要执行该批量操作吗？',function(){
            $("input:checkbox").each(function(index){
                if($(this).is(':checked')==true){
                    var id = $(this).val();
                    if(id){
                        gid += id+','
                    }

                }
            });
            gid = gid.substring(0,gid.length-1);
            if(gid==''){
                layer.msg("请选择要操作的项");
            }else{
                // 由于需要JSON数据，所以使用$.getJSON
                $.getJSON("{:url('admin/ckgl/delete')}", { 'ids': gid }, function(res){
                    layer.msg(res.message,{icon:1,time:1000});
                    window.location.reload();
                });
            }
        });

    }
</script>
</body>
</html>